<template>
  <el-container style="height:100%;overflow-x:auto;" id="maintop">
    <el-dialog
      title="操作确认"
      :visible.sync="showWarning"
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      :show-close="false"
      width="500px">
      <div class="confirm-content" style="font-size: 16px;font-weight: bolder;text-align: center;">
        <p>您在10分钟内未进行任何操作，是否要退出本系统？</p>
        <p class="countdown-text">倒计时: <span class="highlight">{{ countdown }}</span> 秒后自动退出</p>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button type="success" @click="handleCancel">继续使用</el-button>
        <el-button type="danger" @click="handleConfirm">立即退出</el-button>
      </span>
    </el-dialog>
    <el-header height="90px" style="min-width:1400px;position:static;height:90px;overflow:hidden">
      <el-col class="logo" style="width:480px;margin-top:15px;float:left;">
      </el-col>
      <el-col class="userinfo" :style="'width:'+(isDeptUser?'600':'180')+'px; float:right'">
        <el-dropdown trigger="hover">
          <span class="el-dropdown-link userinfo-inner">{{userTrueName}} <img src="./assets/userface.jpg" /></span>
          <el-dropdown-menu slot="dropdown">
            <el-dropdown-item @click.native="handleModPassword">修改密码</el-dropdown-item>
            <!-- <el-dropdown-item @click.native="docsearchwinshow" id="litest">资料查询</el-dropdown-item> -->
            <el-dropdown-item @click.native="setup" id="sysfontsize">字体设置</el-dropdown-item>
            <el-dropdown-item divided @click.native="logout">退出登录</el-dropdown-item>
          </el-dropdown-menu>
        </el-dropdown>
      </el-col>
      <el-col style="margin-left:500px;margin-right:180px;float:none;width:680px;" id="mainmenu" v-if="!isDeptUser">
            <!--导航菜单-->
            <el-menu :default-active="$route.path" :active="navselected" router unique-opened mode="horizontal" :collapse="isCollapse" v-if="!isAdmin">
              <el-menu-item index="/home" exact><i class="el-icon- icon iconfont icon_xtsy"></i><span slot="title">系统首页</span></el-menu-item>
              <el-submenu index="1">
                <template slot="title"><i class="el-icon- icon iconfont icon_jcxx"></i><span slot="title">基础信息</span></template>
                <el-menu-item index="/dept" exact :disabled="!ROLEunit">机构编制</el-menu-item>
                <el-menu-item index="/person" exact :disabled="!ROLEperson">干部信息</el-menu-item>
                <el-menu-item index="/personlist">单位名册</el-menu-item>
                <el-menu-item index="/building">干部档案</el-menu-item>
                <el-menu-item index="/zhidu">人事制度</el-menu-item>
              </el-submenu>
              <!-- <el-menu-item index="/selection"><i class="el-icon- icon iconfont icon_gbxr"></i><span slot="title">干部选任</span></el-menu-item> -->
              <el-submenu index="2">
                <template slot="title"><i class="el-icon- icon iconfont icon_gbxr"></i><span slot="title">干部选任</span></template>
                <!-- <el-menu-item index="/selection" :disabled="!inRoles('ROLE_admin')&&!inRoles('ROLE_xuanren')">干部选任</el-menu-item> -->
                <el-menu-item index="/selection" :disabled="!inRoles('ROLE_admin')&&!ROLExuanren">干部选任</el-menu-item>
                <el-menu-item index="/probation" :disabled="!inRoles('ROLE_admin')&&!inRoles('ROLE_kaohe')">试用期满考核测评</el-menu-item>
              </el-submenu>
              <el-submenu index="3">
                <template slot="title"><i class="el-icon- icon iconfont icon_jypx"></i><span slot="title">教育培训</span></template>
                <el-menu-item index="/building">干部素质体系</el-menu-item>
                <el-menu-item v-if="true" index="/train" :disabled="!trainingAuth">干部培训</el-menu-item>
                <!-- <el-menu-item index="/building">干部培训</el-menu-item> -->
                <el-menu-item index="/building">培养计划</el-menu-item>
              </el-submenu>
              <el-submenu index="4">
                <template slot="title"><i class="el-icon- icon iconfont icon_rcgl"></i><span slot="title">日常管理</span></template>
                <el-menu-item v-if="ver==='dev'" :disabled="!salaryRole" index="/salary">工资管理</el-menu-item>
                <el-menu-item :disabled="!youngCadresRole" :index="youngCadresPath">优秀年轻干部</el-menu-item>
                <el-menu-item index="/shenghuohui" :disabled="!shenghuohuiAuth">民主生活会</el-menu-item>
                <el-menu-item index="/assess" :disabled="!inRoles('ROLE_admin')&&!inRoles('ROLE_kaohe')">干部考核</el-menu-item>
                <el-menu-item index="/candidate" :disabled="!inRoles('ROLE_admin')&&!inRoles('ROLE_kaohe')">候选人民主测评</el-menu-item>
                <el-menu-item index="/person?t=zhfxyp" exact :disabled="!ROLEperson">综合分析研判</el-menu-item>
                <el-menu-item index="/unitReport" :disabled="!inRoles('ROLE_admin')&&!inRoles('ROLE_tianbao')&&!inRoles('ROLE_jijianbianzhi')">统计填报</el-menu-item>
                <el-menu-item index="/fileDistribution" :disabled="!inRoles('ROLE_admin')&&!inRoles('ROLE_xiafa')">资料下发</el-menu-item>
                <el-menu-item v-if="isZhcChuzhang" index="/workRecord/allList">工作日志</el-menu-item>
                <el-menu-item v-else index="/workRecord">工作日志</el-menu-item>
                <el-menu-item index="/meeting" :disabled="!meetingNum">司内会议</el-menu-item>
                <el-menu-item index="/staffing" :disabled="!inRoles('ROLE_admin')&&!inRoles('ROLE_zbbsmz')">机构编制管理</el-menu-item>
                <!-- <el-menu-item v-else index="/zbbsmz/main" :disabled="!inRoles('ROLE_admin')&&!inRoles('ROLE_zbbsmz')">编制统计</el-menu-item> -->
                <el-menu-item index="/jinsheng/main" :disabled="!inRoles('ROLE_jinsheng')">职级晋升年限提示</el-menu-item>
                <el-menu-item index="/jyzd" :disabled="!inRoles('ROLE_admin')&&!inRoles('ROLE_kaohe')">干部队伍状况调研</el-menu-item>
                <el-menu-item index="/zzsz" :disabled="!inRoles('ROLE_admin')&&!inRoles('ROLE_kaohe')">政治素质测评</el-menu-item>
              </el-submenu>
              <el-submenu index="5">
                <template slot="title"><i class="el-icon- icon iconfont icon_gbjd"></i><span slot="title">干部监督</span></template>
                <el-menu-item index="/building">工作监督</el-menu-item>
                <el-menu-item index="/building">干部监督</el-menu-item>
                <el-menu-item index="/cluereport" :disabled="!ROLEjubao">线索举报</el-menu-item>
                <el-menu-item index="/cadrehandling" :disabled="!ROLEchuli">干部处理</el-menu-item>
                <el-menu-item index="/supervision" :disabled="!supervisionAuth">干部监督统计</el-menu-item>
              </el-submenu>
              <el-submenu index="6">
                <template slot="title"><i class="el-icon- icon iconfont icon_rcjs"></i><span slot="title">人才建设</span></template>
                <el-menu-item index="/recruit/main" :disabled="!recruitAuth">公开招聘</el-menu-item>
                <el-menu-item v-if="ver==='dev'" index="/post" :disabled="!postAuth">岗位设置</el-menu-item>
                <el-menu-item index="/building">基本情况</el-menu-item>
                <el-menu-item index="/building">人才规划</el-menu-item>
                <el-menu-item index="/building">服务专家</el-menu-item>
              </el-submenu>
            </el-menu>
      </el-col>
    </el-header>
    <el-container class="main" style="min-width:1400px;">
      <el-scrollbar wrap-style="overflow-x: auto;" style="height: 100%; width:100%;">
        <el-main :style="'padding-left:0px;padding-top:0; height:100%'">
          <div class="mainpage">
            <div class="grid-content bg-purple-light">
            <!--
              <el-col :span="24" class="breadcrumb-container">
                <strong class="title">{{$route.name}}</strong>
                <el-breadcrumb separator="/" class="breadcrumb-inner">
                  <el-breadcrumb-item v-for="item in $route.matched" :key="item.path">
                    {{ item.name }}
                  </el-breadcrumb-item>
                </el-breadcrumb>
              </el-col>
            -->
              <el-col :span="24" class="content-wrapper">
                <transition name="fade" mode="out-in">
                  <router-view :ROLEunit="ROLEunit" :ROLEperson="ROLEperson" :ROLExuanren="ROLExuanren"></router-view>
                </transition>
              </el-col>
            </div>
          </div>
          <el-dialog title="字体设置" :visible.sync="setupFormVisible" >
            <el-form :model="setupForm" label-width="120px" ref="setupForm" style="min-height:300px;">
              <el-form-item label="字体大小" prop="fontsize">
                <el-select v-model="fontsize" placeholder="选择字体大小" @change="changesize">
                  <el-option
                    v-for="(item,index) in fontsizeopt"
                    :key="index"
                    :label="item"
                    :value="item">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-form>
          </el-dialog>
          <el-dialog title="资料查询" :visible.sync="docSearchFormVisible" width="98%" top="20px">
            <doc-search :resetdocform="docSearchFormVisible"></doc-search>
          </el-dialog>
        </el-main>
      </el-scrollbar>
    </el-container>
  </el-container>
</template>
<script>
import DocSearch from '@/components/DocSearch.vue'
export default {
  components: {
    DocSearch
  },
  data () {
    var validateRepetPassword = (rule, value, callback) => {
      if (value === '') {
        callback(new Error('请再次输入新密码'))
      } else if (value !== this.modPasswordForm.NewPassword) {
        callback(new Error('两次输入新密码不一致!'))
      } else {
        callback()
      }
    }
    return {
      ver: '',
      salaryRole: false,
      trainingAuth: false,
      shenghuohuiAuth: false,
      recruitAuth: false,
      postAuth: false,
      pwdtimestamp: '',
      youngCadresPath: '/youngCadres/yearlist',
      youngCadresRole: false,
      isDeptUser: false,
      jubaochuliDisabled: true,
      navselected: '/home',
      sysName: '自然资源部干部人事工作信息系统',
      collapsed: false,
      sysUserName: '',
      sysUserAvatar: '',
      form: {
        name: '',
        region: '',
        date1: '',
        date2: '',
        delivery: false,
        type: [],
        resource: '',
        desc: '',
        doclist: []
      },
      modPasswordFormVisible: false,
      modPasswordFormLoading: false,
      modPasswordForm: {
        OldPassword: '',
        NewPassword: '',
        RepetPassword: ''
      },
      modPasswordFormRules: {
        OldPasswordx: [
          { required: true, message: '请输入原密码', trigger: 'blur' }
        ],
        NewPassword: [
          { required: true, message: '请输入新密码', trigger: 'blur' }
        ],
        RepetPassword: [
          { validator: validateRepetPassword, trigger: 'blur' }
        ]
      },
      userTrueName: '',
      docSearchFormVisible: false,
      isCollapse: false,
      menuwidth: 260,
      changenavbtnicon: 'el-icon-arrow-left',
      fontsizeopt: ['特大', '大', '正常', '小'],
      fontsize: '正常',
      setupFormVisible: false,
      setupForm: {},
      supportcss: false,
      ROLExuanren: false,
      ROLEjubao: false,
      ROLEchuli: false,
      ROLEperson: false,
      ROLEunit: false,
      isZhcChuzhang: false,
      meetingNum: 0,
      supervisionAuth: false,
      showWarning: false,
      countdown: 30,
      countdownTimer: null,
      unsubscribeStore: null,
      isAdmin: true
    }
  },
  methods: {
    setdefualtsize (fontsize) {
      localStorage.setItem('defaultsize', fontsize)
    },
    getdefualtsize () {
      let fontsize = localStorage.getItem('defaultsize')
      if (!fontsize) {
        fontsize = '正常'
      }
      return fontsize
    },
    changesize () {
      let addsize = 0
      if (this.fontsize === '特大') {
        addsize = 4
      }
      if (this.fontsize === '大') {
        addsize = 2
      }
      if (this.fontsize === '正常') {
        addsize = 0
      }
      if (this.fontsize === '小') {
        addsize = -2
      }
      this.setdefualtsize(this.fontsize)
      this.setsize(addsize)
    },
    setsize (addsize) {
      console.log('开始设置字号')
      // eslint-disable-next-line no-undef
      $('body').css('--size', (16 + addsize) + 'px')
      // eslint-disable-next-line no-undef
      $('body').css('--size14', (14 + addsize) + 'px')
      // eslint-disable-next-line no-undef
      $('body').css('--size12', (12 + addsize) + 'px')
      // eslint-disable-next-line no-undef
      $('body').css('--size18', (18 + addsize) + 'px')
      // eslint-disable-next-line no-undef
      $('body').css('--size20', (20 + addsize) + 'px')
      // eslint-disable-next-line no-undef
      $('body').css('--size22', (22 + addsize) + 'px')
      // eslint-disable-next-line no-undef
      $('body').css('--size24', (24 + addsize) + 'px')
      // eslint-disable-next-line no-undef
      $('body').css('--size16', (16 + addsize) + 'px')
      console.log('设置字号结束')
    },
    handleModPassword () {
      this.$router.push({name: 'password'})
      // this.modPasswordFormVisible = true
      // this.modPasswordForm = {
      //   OldPasswordx: '',
      //   NewPassword: '',
      //   RepetPassword: ''
      // }
    },
    setup () {
      this.setupFormVisible = true
    },
    userlist () {
      console.log('changeuser')
      this.$router.push('/user/')
    },
    docsearchwinshow () {
      this.docSearchFormVisible = true
    },
    logout () {
      var _this = this
      this.$http
        .post(`/account/logoff`)
        .then(function (response) {
          _this.listLoading = false
          if (response.data.IsSuccess === true) {
            console.log('注销成功')
            localStorage.clear()
            _this.$router.push({name: 'login'})
          } else {
            console.log('注销失败:' + response.data.Msg)
            _this.$message({
              message: '注销失败:' + response.data.Msg,
              type: 'error'
            })
          }
        })
        .catch(function (error) {
          console.log(error)
          _this.$message({
            message: '网络获取失败:' + error,
            type: 'error'
          })
        })
    },
    modPasswordSubmit: function () {
      var _this = this
      this.$refs.modPasswordForm.validate((valid) => {
        if (valid) {
          _this.modPasswordFormLoading = true
          let para = {
            oldp: _this.modPasswordForm.OldPasswordx,
            newp: _this.modPasswordForm.NewPassword
          }
          this.$http.post(`/admin/changepassword`, para).then(function (response) {
            console.log(response.data.IsSuccess)
            if (response.data.IsSuccess === true) {
              _this.$message({
                message: '修改密码成功',
                type: 'success'
              })
              _this.modPasswordFormLoading = false
              _this.modPasswordFormVisible = false
            } else {
              console.log('修改密码失败:' + response.data.Msg)
              _this.$message({
                message: '修改密码失败:' + response.data.Msg,
                type: 'error'
              })
              _this.modPasswordFormLoading = false
            }
            _this.$refs['modPasswordForm'].resetFields()
          }).catch(function (error) {
            console.log(error)
            _this.$message({
              message: '修改密码失败:' + error,
              type: 'error'
            })
            _this.$refs['modPasswordForm'].resetFields()
            _this.modPasswordFormLoading = false
          })
        }
      })
    },
    showmenu: function () {
      let _this = this
      this.$http.post(`/account/userinfo`).then(function (response) {
        console.log(response.data.IsSuccess)
        if (response.data.IsSuccess === true) {
          _this.userTrueName = response.data.TrueName
          localStorage.setItem('userTrueName', response.data.TrueName)
        } else {
          console.log('获取失败:' + response.data.Msg)
        }
      }).catch(function (error) {
        console.log(error)
      })
    },
    changenav: function () {
      if (this.isCollapse === true) {
        this.isCollapse = false
        this.menuwidth = 260
        this.changenavbtnicon = 'el-icon-arrow-left'
      } else {
        this.isCollapse = true
        this.menuwidth = 80
        this.changenavbtnicon = 'el-icon-arrow-right'
      }
    },
    inRoles (str) {
      let arr = JSON.parse(localStorage.getItem('Roles'))
      // arr = 'aaabbROLE_admin'
      if (arr.indexOf(str) === -1) {
        return false
      } else {
        return true
      }
    },
    checkJibenRole () {
      this.$http
        .get(`binfo/getCurrentAuth`)
        .then(response => {
          this.ROLEperson = response.data.personright
          this.ROLEunit = response.data.unitright
        })
        .catch(error => {
          if (error.status === 500) {
            this.$message({
              message: '网络获取失败:' + error,
              type: 'error'
            })
          }
        })
    },
    checkSelectionRole () {
      this.$http
        .get(this.$http.defaults.selectionAPI + `api/selection/auth/getCurrentAuth`)
        .then(response => {
          if (response.data.success) {
            this.ROLExuanren = response.data.result.xuanren
            this.ROLEjubao = response.data.result.jubao
            this.ROLEchuli = response.data.result.chuli
          } else {
            this.$message({
              message: '获取失败:' + response.data.message,
              type: 'error'
            })
          }
        })
        .catch(error => {
          if (error.status === 500) {
            this.$message({
              message: '网络获取失败:' + error,
              type: 'error'
            })
          }
        })
    },
    checkyoungCadresRole () {
      if (this.inRoles('ROLE_youngadmin')) {
        this.youngCadresRole = true
        this.youngCadresPath = '/youngCadres/yearlist'
      } else {
        this.$http
          .get(this.$http.defaults.youngAPI + `api/young/security/getCurrentAuth`)
          .then(response => {
            if (response.data.success) {
              this.youngCadresRole = response.data.result
              if (this.youngCadresRole && !this.inRoles('ROLE_admin')) {
                if (this.inRoles('ROLE_banshirenyuan')) {
                  this.$http
                    .get(this.$http.defaults.youngAPI + `api/busTrialUser/getIfTrialUser`)
                    .then(response => {
                      if (response.data.success) {
                        this.youngCadresRole = response.data.result.isTrialUser
                      } else {
                        this.$message({
                          message: '获取失败:' + response.data.message,
                          type: 'error'
                        })
                      }
                    })
                    .catch(error => {
                      if (error.status === 500) {
                        this.$message({
                          message: '网络获取失败:' + error,
                          type: 'error'
                        })
                      }
                    })
                } else if (this.inRoles('ROLE_fusizhang')) {
                  this.$http
                    .get(this.$http.defaults.youngAPI + `api/young/security/getCurrentManageDep`)
                    .then(response => {
                      if (response.data.success) {
                        if (response.data.result && response.data.result.length > 0) {
                          // this.youngCadresRole = true
                          this.youngCadresPath = '/youngCadres/yearlist'
                          // 2024年8月修改，主管干部处以外的副司长，也可以进入年轻干部模块
                          // } else {
                          //   this.youngCadresRole = false
                        }
                      } else {
                        this.$message({
                          message: '获取失败:' + response.data.message,
                          type: 'error'
                        })
                      }
                    })
                    .catch(error => {
                      if (error.status === 500) {
                        this.$message({
                          message: '网络获取失败:' + error,
                          type: 'error'
                        })
                      }
                    })
                } else if (this.inRoles('ROLE_chuzhang')) {
                  if (localStorage.getItem('unitName') === '干部一处' || localStorage.getItem('unitName') === '干部二处' || localStorage.getItem('unitName') === '干部三处') {
                    this.youngCadresRole = true
                  } else {
                    this.youngCadresRole = false
                  }
                }
              }
            } else {
              this.$message({
                message: '获取失败:' + response.data.message,
                type: 'error'
              })
            }
          })
          .catch(error => {
            if (error.status === 500) {
              this.$message({
                message: '网络获取失败:' + error,
                type: 'error'
              })
            }
          })
        // this.youngCadresRole = false
        if (this.inRoles('ROLE_sizhang') || this.inRoles('ROLE_fusizhang')) {
        // this.youngCadresRole = true
          this.youngCadresPath = '/youngCadres/yearlist'
        }
        if (this.inRoles('ROLE_chuzhang')) {
          if (localStorage.getItem('unitName') === '干部一处' || localStorage.getItem('unitName') === '干部二处' || localStorage.getItem('unitName') === '干部三处') {
          // this.youngCadresRole = true
            this.youngCadresPath = '/youngCadres/yearlist'
          }
        }
      }
    },
    checkZhcChuzhang () {
      console.log('检验是否是综合处处长')
      console.log(this.inRoles('ROLE_chuzhang'))
      console.log(localStorage.getItem('unitName'))
      if (this.inRoles('ROLE_chuzhang') && localStorage.getItem('unitName') === '综合处') {
        this.isZhcChuzhang = true
      } else {
        this.isZhcChuzhang = false
        this.$http
          .get(this.$http.defaults.workRecordAPI + `api/manageuser/getCurrentIfManageUser`)
          .then(response => {
            if (response.data.success) {
              this.isZhcChuzhang = response.data.result
            } else {
              this.$message({
                message: '获取失败:' + response.data.message,
                type: 'error'
              })
            }
          })
          .catch(error => {
            if (error.status === 500) {
              this.$message({
                message: '网络获取失败:' + error,
                type: 'error'
              })
            }
          })
      }
    },
    getShhAuth () {
      if (this.inRoles('ROLE_shhadmin') || this.inRoles('ROLE_admin')) {
        this.shenghuohuiAuth = true
        localStorage.setItem('shhAuth', 2)
      } else {
        this.$http
          .get(this.$http.defaults.shenghuohuiAPI + `api/newAuth/getCurrentUserAuth`)
          .then(response => {
            if (response.data.success) {
              if (response.data.result) {
                this.shenghuohuiAuth = true
                localStorage.setItem('shhAuth', response.data.result.auth)
                localStorage.setItem('type1', response.data.result.type1)
                localStorage.setItem('type2', response.data.result.type2)
                localStorage.setItem('type3', response.data.result.type3)
              }
            } else {
              this.$message({
                message: '获取失败:' + response.data.message,
                type: 'error'
              })
            }
          })
          .catch(error => {
            if (error.status === 500) {
              this.$message({
                message: '网络获取失败:' + error,
                type: 'error'
              })
            }
          })
      }
    },
    getRecruitAuth () {
      if (this.inRoles('ROLE_recruit') || this.inRoles('ROLE_admin')) {
        this.recruitAuth = true
      } else {
        this.$http
          .get(this.$http.defaults.recruitAPI + `api/recruitBusAuth/currentHasAuth`)
          .then(response => {
            if (response.data.success) {
              this.recruitAuth = response.data.result
            } else {
              this.$message({
                message: '获取失败:' + response.data.message,
                type: 'error'
              })
            }
          })
          .catch(error => {
            if (error.status === 500) {
              this.$message({
                message: '网络获取失败:' + error,
                type: 'error'
              })
            }
          })
      }
    },
    getSalaryAuth () {
      if (this.inRoles('ROLE_salary') || this.inRoles('ROLE_admin')) {
        this.salaryRole = true
      }
    },
    getPostAuth () {
      if (this.inRoles('ROLE_post') || this.inRoles('ROLE_admin')) {
        this.postAuth = true
      // } else {
      //   this.$http
      //     .get(this.$http.defaults.postAPI + `api/newAuth/getCurrentUserAuth`)
      //     .then(response => {
      //       if (response.data.success) {
      //         if (response.data.result) {
      //           this.postAuth = true
      //         }
      //       } else {
      //         this.$message({
      //           message: '获取失败:' + response.data.message,
      //           type: 'error'
      //         })
      //       }
      //     })
      //     .catch(error => {
      //       if (error.status === 500) {
      //         this.$message({
      //           message: '网络获取失败:' + error,
      //           type: 'error'
      //         })
      //       }
      //     })
      }
    },
    getSupervisionAuth () {
      this.$http
        .get(this.$http.defaults.supervisionAPI + `api/statsProjectData/getModuleAuth`)
        .then(response => {
          if (response.data.success) {
            this.supervisionAuth = response.data.result
          } else {
            this.$message({
              message: '获取失败:' + response.data.message,
              type: 'error'
            })
          }
        })
        .catch(error => {
          if (error.status === 500) {
            this.$message({
              message: '网络获取失败:' + error,
              type: 'error'
            })
          }
        })
    },
    getTrainingAuth () {
      if (this.inRoles('ROLE_training')) {
      // 培训模块管理员可以进入培训模块，并有编辑权限
        this.trainingAuth = true
        localStorage.setItem('trainingAuth', 2)
      } else {
        // 一二三处人员、主管培训处副司长、司长可以进入培训模块
        this.$http
          .get(this.$http.defaults.trainingAPI + `api/trainingBusAuth/getHasTrainingAuth`)
          .then(response => {
            if (response.data.success) {
              if (response.data.result) {
                this.trainingAuth = true
                localStorage.setItem('trainingAuth', 2)
              } else {
                // 模块内被授权用户可以进入培训模块
                this.$http
                  .get(this.$http.defaults.trainingAPI + `api/trainingBusAuth/getCurrentUserAuth`)
                  .then(res => {
                    if (res.data.success) {
                      if (res.data.result.length > 0) {
                        this.trainingAuth = true
                        if (res.data.result[0] && res.data.result[0].auth) {
                          localStorage.setItem('trainingAuth', res.data.result[0].auth)
                        }
                      } else {
                        // 系统管理员可以进入培训模块
                        if (this.inRoles('ROLE_admin')) {
                          this.trainingAuth = true
                          localStorage.setItem('trainingAuth', 1)
                        } else {
                          this.trainingAuth = false
                        }
                      }
                    } else {
                      this.$message({
                        message: '获取失败:' + res.data.message,
                        type: 'error'
                      })
                    }
                  })
                  .catch(error => {
                    if (error.status === 500) {
                      this.$message({
                        message: '网络获取失败:' + error,
                        type: 'error'
                      })
                    }
                  })
              }
            } else {
              this.$message({
                message: '获取失败:' + response.data.message,
                type: 'error'
              })
            }
          })
          .catch(error => {
            if (error.status === 500) {
              this.$message({
                message: '网络获取失败:' + error,
                type: 'error'
              })
            }
          })
      }
    },
    getMeetingNum () {
      if (this.inRoles('ROLE_meeting')) {
        this.meetingNum = 1
      } else {
        let para = {
          status: 1,
          pageNum: 1,
          pageSize: 1
        }
        this.listLoading = true
        // var personParams = { Page: 0, Pagenum: 20, Personname: '', Unitkey: '', Sortkey: '', Isace: true, timestamp: new Date().getTime() }
        this.$http
          .post(this.$http.defaults.meetingAPI + `api/meetingBusTask/queryByPage`, para)
          .then(response => {
            this.meetingNum = response.data.result.total
          })
          .catch(error => {
            this.$message({
              message: '获取失败:' + error,
              type: 'error'
            })
          })
      }
    },
    startCountdown  () {
      this.countdown = 30 // 30秒倒计时
      if (this.countdownTimer) {
        clearInterval(this.countdownTimer)
        this.countdownTimer = null
      }
      this.countdownTimer = setInterval(() => {
        this.countdown--
        if (this.countdown <= 0) {
          if (this.countdownTimer) {
            clearInterval(this.countdownTimer)
            this.countdownTimer = null
          }
          this.logout()
        }
      }, 1000)
    },
    handleCancel () {
      if (this.countdownTimer) {
        clearInterval(this.countdownTimer)
        this.countdownTimer = null
      }
      this.countdownTimer = null
      this.$idleService.reset()
      this.$store.dispatch('showIdleWarning', false)
      this.$store.dispatch('sendHeartbeat')
      this.checkJibenRole() // 调用root包任意接口用来保持心跳
    },
    handleConfirm () {
      if (this.countdownTimer) {
        clearInterval(this.countdownTimer)
        this.countdownTimer = null
      }
      this.$idleService.reset()
      this.$store.dispatch('showIdleWarning', false)
      console.log('立即退出按钮触发退出系统')
      this.logout()
      this.showWarning = false
    },
    getPasswordExpire () {
      this.$http
        .get(`/admin/passwordExpired`)
        .then(response => {
          if (response.data) {
            this.$notify({
              title: '密码过期提示',
              dangerouslyUseHTMLString: true,
              message: '您的密码已过期，请尽快修改密码',
              type: 'warning',
              offset: 100
            })
          }
        })
        .catch(error => {
          if (error.status === 500) {
            this.$message({
              message: '网络获取失败:' + error,
              type: 'error'
            })
          }
        })
    }
  },
  created () {
    if (this.isDeptUser) {
      this.$router.push('/unit/youngCadresDept')
    }
  },
  mounted () {
    this.getPasswordExpire()
    if (this.inRoles('ROLE_admin_audit') || this.inRoles('ROLE_admin_sys') || this.inRoles('ROLE_admin_right')) {
      this.$router.push({name: 'Map'})
      this.isAdmin = true
    } else {
      this.isAdmin = false
    }
    this.unsubscribeStore = this.$store.subscribe((mutation) => {
      console.log('当前触发的 mutation 类型:', mutation.type)
      if (mutation.type === 'SET_IDLE_WARNING') {
        console.log('订阅到 showIdleWarning 事件', mutation.payload)
        this.showWarning = mutation.payload
        if (this.showWarning) {
          this.startCountdown()
        }
      }
    })
    this.ver = document.querySelector('meta[name="ver"]').content
    this.showmenu()
    this.fontsize = this.getdefualtsize()
    this.changesize()
    // eslint-disable-next-line no-undef
    let displaycss = $('#litest').css('display')
    console.log('displaycss')
    console.log(displaycss)
    // eslint-disable-next-line no-undef
    $('#app').css('--showmenu', displaycss)
    if (!this.isAdmin) {
      this.checkJibenRole()
      this.checkSelectionRole()
      this.checkyoungCadresRole()
      this.checkZhcChuzhang()
      this.getShhAuth()
      this.getRecruitAuth()
      this.getSupervisionAuth()
      if (this.ver === 'dev') {
        this.getPostAuth()
        this.getSalaryAuth()
      }
      this.getTrainingAuth()
      this.getMeetingNum()
    }
    // 临时屏蔽工作日志
  },
  beforeDestroy () {
    if (this.unsubscribeStore) {
      console.log('取消订阅')
      this.unsubscribeStore() // 关键：取消订阅
      this.unsubscribeStore = null // 释放引用
    }
  }
}
</script>
<style>
.el-upload{
  position: relative;
  display: inline-block;
}
.el-upload::after{
  content: " ";
  font-size: 12px;
  z-index: 1;
  width: 140px;
  height: 20px;
  position: absolute;
  top: -30%;
  left: 30%;
  white-space: nowrap;
  pointer-events: none;
  background: url(./assets/tips.png) no-repeat;
}
.el-upload:hover::after {
    display: none;
}
.el-menu--horizontal .el-menu .el-menu-item, .el-menu--horizontal .el-menu .el-submenu__title{
  color: #000 !important;
}
.el-menu--horizontal .el-menu .el-menu-item:hover {
  background: #003d79 !important;
  color: #9ecade !important;
}
.el-menu--horizontal .el-menu .el-menu-item.is-active {
    background: #002e5b !important;
    color: #9ecade !important;
    font-weight: bolder;
}
i.icon-wenjianjia1{
  color:#ffc500 !important;
}
i.icon-danwei{
  color:#1296db !important;
}
i.icon-cf-c24{
  color:#6fb400 !important;
}
i.warning{
  color:red
}
i.tmp{
  color:#e6a23c
}
      .el-submenu__icon-arrow{
        display: none;
      }
.el-menu-item.is-active{
  background:#002e5b !important;
  color: #9ecade !important;
  font-weight: bolder;
}
.el-menu-item:hover{
  background:#003d79 !important;
  color: #9ecade !important;
}
.el-menu-item:hover span, .el-submenu__title:hover span{
  color:#000;
}
.el-menu--collapse .el-menu .el-submenu, .el-menu--popup{
  min-width: 90px !important;
}
.el-menu--horizontal .el-menu .el-menu-item.is-disabled{
  opacity:1 !important;
  background: #fff !important;
  color:#999 !important;
}
.el-menu{
  font-family: '宋体';
  background: none;
  text-align: center;
  background: transparent !important;
}
.el-menu--horizontal>.el-menu-item{
  height: 90px !important;
}.el-menu--horizontal>.el-submenu .el-submenu__title{
  height: 90px !important;
  padding: 0 10px !important;
}
.el-menu--horizontal>.el-menu-item span, .el-menu--horizontal>.el-submenu .el-submenu__title span{
  clear: both;
  text-align: center;
  display: block;
  line-height: 20px;
  font-size: 16px;
  font-weight: bolder;
  color: #fff;
}
#sysfontsize{
  display: none;
  padding-top:12px;
  padding-bottom:12px;
  display: var(--showmenu) !important;
}

body .el-table th.gutter{
    display: table-cell!important;
}

body .el-table colgroup.gutter{
    display: table-cell!important;
}

.icon_xtsy{
  background: url(./assets/icon_xtsy.png) no-repeat;
}
.icon_jcxx{
  background: url(./assets/icon_jcxx.png) no-repeat;
}
.icon_gbxr{
  background: url(./assets/icon_gbxr.png) no-repeat;
}
.icon_jypx{
  background: url(./assets/icon_jypx.png) no-repeat;
}
.icon_rcgl{
  background: url(./assets/icon_rcgl.png) no-repeat;
}
.icon_gbjd{
  background: url(./assets/icon_gbjd.png) no-repeat;
}
.icon_rcjs{
  background: url(./assets/icon_rcjs.png) no-repeat;
}
.icon_setting{
  background: url(./assets/icon_setting.png) no-repeat;
}
i.el-icon-{
  width: 36px !important;
  height: 36px;
  margin-right:0 auto;
  margin-left:0 !important;
}
.el-submenu__title{
  font-size:var(--size14) !important;
  color:#fff !important;
}
.is-opened .el-submenu__title{
  background:#003d79 !important;
}
.is-active .el-submenu__title{
  background:#003d79 !important;
}
.el-pagination{
  float:right;
  padding: 10px;
}
.el-pagination__sizes{
  /* float: right; */
}
.el-table{
  font-size:var(--size) !important;
  color: #000 !important;
}
.el-dialog__body{
  color: #000 !important;
}
#app{
  color: #000 !important;
}
.el-form--inline .el-form-item__content{
  /* text-decoration: underline; */
}
.el-form-item__label{
  color: #000 !important;
}
.el-checkbox{
  color: #000 !important;
}
.el-checkbox__input.is-checked+.el-checkbox__label{
  color: #0000FF !important;
}
.el-tabs--border-card>.el-tabs__header .el-tabs__item.is-active{
  color: #0000FF !important;
}
.el-tabs--border-card>.el-tabs__header .el-tabs__item{
  color: #000 !important;
}
.el-tree{
  color: #000 !important;
}
.el-table thead{
  color: #000 !important;
  font-size:var(--size14) !important;
}
.el-button{
  color: #000 !important;
}
.el-button--primary, .el-button--success, .el-button--danger{
  color: #fff !important;
}
.el-button--primary.is-plain{
  color: #0000FF !important;
}
.el-tabs__item.is-active{
  color: #0000FF !important;
}
.el-radio-button__inner{
  color: #0000FF !important;
}
.el-radio-button__orig-radio:checked+.el-radio-button__inner{
  color:#fff !important;
}
.el-step__title.is-success{
  color:#006600 !important;
}
.el-step__title.is-finish{
  color: #0000FF !important;
}
.el-step__title.is-wait{
  color: #000 !important;
}
.el-card{
  background:#F5F7FA !important;
}
.el-dropdown-link{
  font-size:var(--size14) !important;
}
h1{
  font-size:var(--size18) !important;
}
.list_cygn li a{
  font-size:var(--size18) !important;
}
.list_ywbl li{
  font-size:var(--size14) !important;
}
#optForm *,
.el-popover__title,
.el-card,
.el-tab-pane,
.el-form-item__content,
.el-form-item__label,
.el-radio__label{
  font-size:var(--size) !important;
}
.el-tabs__item,
.el-checkbox__label,
.custom-tree-node,
.el-button,
input,
#editswitch,
.el-switch__label *,
.el-breadcrumb,
.el-popover,
.el-radio-button__inner{
  font-size:var(--size14) !important;
}
.el-dialog__title{
  font-size:var(--size18) !important;
}
.el-tag,
.el-progress-bar__innerText{
  font-size:var(--size12) !important;
}
.bigfont{
  font-size:var(--size20) !important;
}
.el-radio{
  color: #000;
}
.el-breadcrumb{
  font-family: '宋体';
  font-size: 12px;
  padding: 10px;
}
.el-breadcrumb__separator{
  font-family: '宋体';
  color:#333;
  font-weight: normal;
  font-size: 12px;
}
.el-breadcrumb__inner is-link,el-breadcrumb__item{
  font-family: '宋体';
  font-size: 12px;
}
</style>
<style lang="scss" scoped>
html{
  height: 100%;
}
header{
  width: 100%;
  position: fixed;
  background: #0058AC;
  line-height: 90px;
  color: #fff;
  background: url(./assets/topback.jpg) no-repeat right #0058AC;
  top:0;
}
.main{
  height: calc(100% - 90px);
  background: #D6E3F2;
}
.el-main{
  // width: calc(100% - 260px);
}
.mainpage{
  // padding:0 20px;
}
aside{
  // width:260px;
  background:#0874c8;
  height:100%;
  position: fixed;
  top: 0;
  bottom: 0;
  margin-top: 90px;
  box-shadow:inset -15px 0 10px -17px #000;
}
.logo {
  width: 567px;
  height: 61px;
  background: url(./assets/title.png) no-repeat;
  margin: 0;
  font-weight: bolder;
}
    .userinfo {
      text-align: right;
      padding-right: 5px;
      float: right;
      .userinfo-inner {
        cursor: pointer;
        color: #fff;
        img {
          width: 40px;
          height: 40px;
          border-radius: 20px;
          margin: 25px 0px 10px 10px;
          float: right;
        }
      }
    }
      .breadcrumb-container {
        //margin-bottom: 15px;
        .title {
          width: 200px;
          float: left;
          color: #475669;
        }
        .breadcrumb-inner {
          float: right;
        }
      }
      .content-wrapper {
        box-sizing: border-box;
      }
</style>
